-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (37 loc) · 1.07 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
int main() {
int i, N, quantia, somaC = 0, somaR = 0, somaS = 0, totalCobaia;
double porC, porR, porS;
char tipo;
cin >> N;
for(i = 0; i < N; i++){
do{
cin >> quantia >> tipo;
}while(tipo != 'C' && tipo != 'R' && tipo != 'S');
switch (tipo){
case 'C':
somaC += quantia;
break;
case 'R':
somaR += quantia;
break;
case 'S':
somaS += quantia;
}
}
totalCobaia = somaC + somaR + somaS;
porC = (double)(100 * somaC) / totalCobaia;
porR = (double)(100 * somaR) / totalCobaia;
porS = (double)(100 * somaS) / totalCobaia;
cout << fixed;
cout.precision(2);
cout << "Total: " << totalCobaia << " cobaias" << endl;
cout << "Total de coelhos: " << somaC << endl;
cout << "Total de ratos: " << somaR << endl;
cout << "Total de sapos: " << somaS << endl;
cout << "Percentual de coelhos: " << porC << " %" << endl;
cout << "Percentual de ratos: " << porR << " %" << endl;
cout << "Percentual de sapos: " << porS << " %" << endl;
return 0;
}